AGB provides the following five functions.
1. 8-Bit/32-Bit Normal Communication Function
Use of a DMG/MGB cable is prohibited for Normal Communications. It is possible to communicate with peripherals that do not use cables at 256 KHz and 2 MHz.
In extraordinary circumstances, normal communications using a communication cable exclusively for AGB is possible. However, this communication can only be performed in one direction, because of distribution and connections for multi-play communications. Also, this type of communication is only possible at 256KHz.
Communication between AGB and CGB is not possible due to differences in voltages.
2. 16-Bit Multi-player Communication Function
This multiple/simultaneous communication function uses a UART system to enable communication of up to 4 AGB units. A special cable for Multi-player communication is necessary.
3. UART Communication Function
Enables high-speed communication by UART system.
4. General Purpose Communication Function
Enables communication by any protocol through direct control of the communication terminal.
5. JOY Bus Communication Function
Enables communication using Nintendos standardized Joy bus.
All the communication functions use an external expansion 6-pin connector. Communication functions are switched by the communication function set flag of the communication control register R (2-bit) and the communication mode set flag of the serial communication control register SCCNT_L (2-bit), which are described later.
Communication Functions |
R |
SCCNT_L |
||
d15 |
d14 |
d13 |
d12 |
|
General Purpose |
1 |
0 |
* |
* |
JOY Bus |
1 |
1 |
* |
* |
8-Bit Serial |
0 |
* |
0 |
0 |
32-Bit Serial |
0 |
* |
0 |
1 |
16-Bit Serial |
0 |
* |
1 |
0 |
UART |
0 |
* |
1 |
1 |
Do not change or reset a communication mode during communication, as this may cause a communication malfunction.
When changing communication modes, change only the communication mode set flag first. Do not start a communication at the same time as you change modes. This may cause a malfunction.
If a communication isn't finished (SIO interrupt does not occur) after a certain period of time, or if there is a communication error after retries, enter another communication mode once and then re-enter the communication mode once again. By doing this, the communication circuit will be reset.
[Cautions for Communication Function]
When communicating, try to avoid lock-ups or malfunctions by considering the various circumstances listed below:
(Example: To permit canceling a communication by pressing a key.)
Examples of Communication Failure
When peripheral equipment that is not compatible is connected.
When different software is connected to the other machine.
When a communication mode is different from the other machine.
When a communication cable is connected incorrectly.
When unexpected data is received.
Serial transfer sends/receives simultaneously.
If data is set in the data register and the serial transfer is started, received data is set in the data register when the transfer is complete.
Master (internal clock mode) will output the shift clock from SC terminal. SD terminal will become an input terminal with pull-up.
In the case of a slave(external clock mode), SC terminal will become an input terminal with pull-up. SD terminal will go to LO output.
The set data will be left-shifted by the falling of the shift clock, and will be output from the SO terminal in order starting from the most significant bit. The data input from SI terminal will be input to the least significant bit with the rising of the shift clock.
The above figure illustrates 8 bit communication. In 32 bit communication, the shift clock sends and receives 32 bits of
data.
8-bit transfer mode uses SCCNT_H as a data register. Upper 8-bits will become disabled.
32-bit transfer mode uses [120h:SCD0] and [122h:SCD1] as data registers.(These data registers are used for 16-bit multi-player communication also.)
The most significant bit will be d15 in the register SCD1, and the least significant bit will be d0 in the register SCD0.
When Register R (d15) = (0), the mode will be 8-bit normal serial communication mode by setting to Register SCCNT_L (d13, d12) = (0,0), and the mode will be 32-bit normal serial communication mode by setting to SCCNT_L (d13, d12) = (0, 1).
SCCNT_L [d14] Interrupt Request Enable Flag
If 0 is set, an interrupt request will not be made.
If 1 is set, an interrupt request will be made immediately after transfer is complete.
SCCNT_L [d12] Transfer Length Setting Flag
Sets bit length of transfer data.
If 0, 8-bit transfer is carried out. If 1, 32-bit transfer is carried out.
SCCNT_L [d07] Start Bit
With a setting of 1, a serial transfer starts. The bit is automatically reset after transfer completion.
SCCNT_L [d03] Transfer Enable Flag Send
A setting of 0 enables transfer; 1 disables it.
This flag is output from the SO terminal until the start of a transfer. When the transfer starts, serial data are output from the SO terminal.
SCCNT_L [d02] Transfer Enable Flag Receive
It is possible to read the status of SI terminal (transfer-enable flag transmitting of the other party's hardware) before communication starts.
It becomes invalid after communication has started.(receive data bit during communication is reflected.)
SCCNT_L [d01] Internal Shift Clock Selection
If 0, 256KHz is selected for the shift clock.
If 1, 2MHz is selected for the shift clock.
SCCNT_L [d00] Shift Clock Selection
If 0, an external clock is used as a shift clock (slave).
The external clock is input by the SC terminal from another hardware unit. SD terminal will go to LO output.
If 1, an internal clock is used as a shift clock (master).
The internal clock is output from the SC terminal, and SD terminal will be in the pull-up input status.
[Cautions for Normal Serial Communication]
The shift clock should be selected before the start bit of the SCCNT_L register is set. Extra shift operations may result if the serial transfer is started before or at the same time as the shift clock is selected.
The SCCNT_L register should not be accessed while its start bit is set.
The 8 bit transfer mode is compatible in terms of modes with DMG/CGB, but the voltage with the communication terminal varies. Therefore, communication between AGB and DMG/CGB is not possible.
For normal communication, use of cable is prohibited.
In order to communicate between AGBs, use the Multi player communication functions discussed later.
AGB enables multi-player communication between up to 4 units using a special cable.
Depending on the connection status, 1 unit is established as the master and transfers data to slaves in order, one after another.
In multi-player communication mode the SC and SD become pull-up input terminals. Immediately following a reset or in another communication mode, LO is output from the SD terminal. Once the SD terminal becomes HI, you can tell that all connected terminals have entered multi-player communication mode.
The SI terminal is in pull-up input, but due to the multi-player communication cable it becomes pull-down. Thus, once all of the terminals are in multi-player mode, the terminal that is LO input to the SI terminal becomes the master. The terminal that is HI input to the SI terminal becomes the slave.
If you set the start bit of Register SCCNT_L of the master, the data registers SCD0, SCD1, SCD2, and SCD3 of the master are initialized to FFFFh.
Additionally, the "SYNC signal" (LOW level) is output from the SC terminal. At the same time, the "Start bit" (LO level) is output from the SD terminal. Next, the data from Register SCCNT_H is output and a ""Stop bit" (HI level) is output.
After this is done, the master makes the SD terminal become pull-up input, and LO is output from the SO terminal.
Each slave detects the "SYNC Signal" output from the master and initializes all of the data registers (SCD0, SCD1, SCD2, and SCD3) to FFFFh. The data output from the master is stored in the master and each slaves SCD0 register.
If LO is input to the SI terminal of the slave which was connected immediately following the master, a "Start bit" (LO level) is output from the SD terminal. Next, data from Register SCCNT_H is output, and lastly a "Stop bit" (HI level) is output.
After this, the SD terminal goes to pull-up input and LO is output from the SO terminal.
At this point, the data output from the first slave is stored in the master and each slave's SCD1 Register.
In this way, each slave is sent and all transmissions are carried out.
In the following situations the master produces a "SYNC Signal" (pull-up input after the output of a 5 cycle HI interval of source oscillation) and the transmission ends:
Once the transmission ends, the received data is stored in each of the data registers (SCD0, SCD1, SCD2, and SCD3). If there is a terminal that is not connected the initial data FFFFh is stored.
The data send is stored in the Register SCCNT_H.
After completion of multi-player communication ends, the send data for the master is in SCD0.
If you set Register SCCNT_L (d13,d12) = (1,0) when Register R (d15) = (0), you will go to 16-bit multi-player communication mode.
SCCNT_L [d14] Interrupt Request Enable Flag
When set to 0, no interrupt request is generated.
When set to 1, an interrupt request is generated upon the completion of multi-player communication.
SCCNT_L [d07] Start Bit/Busy Flag
1)Master (d00 is 1)
When set to 0, no data is transferred.
When set to 1, a data transfer is started. Upon completion of data transfer, it is automatically reset.
[Caution]
Due to individual differences in AGB hardware, there is an error in timing of interrupt occurrence. Always use a timer when sending, and be sure to have enough intervals of communicable minimum send interval + 600 clock (interrupt occurrence error guarantee value).
2)Slave (d00 is 0)
Set during input of transmit start bit (LO source oscillation cycle × 3 (approx. 180ns)), and reset when transfer is complete.
SCCNT_L [d06] Communication Error Flag
The communication status can be confirmed at the end of a communication. (During communication, it is not reflected properly.)
If the status for this bit is 0, there is no error. If it is 1, it means an error has occurred.
This error flag is automatically set in the following situations:
- The SI Terminal does not become LO during the interval when the "SYNC signal" is being input (the master is outputting).
- The stop bit for the receive data is not HI (Framing Error)
However, even if an error occurs, the communication continues, and invalid data is stored in SCD0-SCD3.
SCCNT_L [d05-d04] Multi-player ID Flag
When multi-player communication ends, an ID code will be stored which specifies the order that each particular machine was connected.
SCCNT_L [d03] SD Terminal
The status of the SD Terminal can be read.
If all of the connected terminals enter multi-player communication mode, it becomes HI status.
SCCNT_L [d02] SI Terminal
The status of the SI Terminal can be read.
When all of the connected terminals are in multi-player communication mode, this shows that the terminal which is LO input to the SI terminal is the master. HI input means that it is a slave.
Prior to communication starting, it is not possible to determine the number order of a particular slave.
SCCNT_L [d01-d00] Baud Rate
Sets the communication baud rate.
Setting |
Baud Rate |
00 |
9600 bps |
01 |
38400 bps |
10 |
57600 bps |
11 |
115200 bps |
UART communications can be illustrated using the following drawing.
In UART communication mode, a HI level is output from the SD terminal.
When the receive data register (or the receive FIFO) is full, a HI is output from the SD terminal. When it is not full, a LO is output from the SD terminal if the receive enable flag is set. A HI is output if it is reset.
The output of the SD terminal of the other machine is input to the SC terminal.
Once data is written to the send data register, data is sent after a "Start bit" (1 bit) is sent from the SO terminal. However, when the CTS flag for the Control Register is set, data can be sent only when there is a LO input to the SC terminal. The Stop bit is a fixed 1 bit.
When sending or receiving, there are 4 bytes of FIFO. By using the FIFO enable flag for the control register SCCNT_L, you can select whether to use or not use FIFO.
When FIFO is not Used
If written to a data register SCCNT_H, data is written to a send shift register, andif read, data is read from a receive shift register. (Only the lower 8 bits are valid.)
When FIFO is Used
If written to a data register SCCNT_H, data is written to a send FIFO. If all the contents of the send shift register are shifted out, data is transferred from a send FIFO to a shift register immediately.
Please note that when using this operation, that data is immediately transferred to a shift register when the first data is written to the data register, and the interrupt request condition is met as a send FIFO becomes empty. Also when read, data is read from a receive FIFO. (Only the lower 8 bits are valid.)
Example: Writing Data Registers
If Register SCCNT_L (d13,d12) = (1,1) is set when Register R (d15) = (0), you will go to UART communication mode.
align="center">
SCCNT_L [d14] Interrupt Request Enable Flag
When set to 0, an interrupt request is not generated.
When set to 1 and FIFO is invalid, an interrupt request is generated when a communication error occurs or when the transmission (send/receive) ends.
When set to 1 and FIFO is valid, an interrupt request is generated when a communication error occurs, when a send FIFO is emptied, or a receive FIFO becomes full.
SCCNT_L [d11] Receive Enable Flag
Controls the receive enable/disable.
If the receive enable flag is set when the receive data register (or the receive FIFO) is not full, a LO is output from the SD terminal, and a HI is output if it is reset.
You must first set the receive enable flag and send enable flag to 0 [Disable] before going from UART communication mode to a different communication mode.
SCCNT_L [d10] Send Enable Flag
Controls the send enable/disable.
You must first set the receive enable flag and send enable flag to 0 [Disable] before going from UART communication mode to a different communication mode.
SCCNT_L [d09] Parity Enable Flag
Controls the parity enable/disable.
SCCNT_L [d08] FIFO Enable Flag
Controls the send of the 8 bit wide × 4 depth and the receive FIFO enable/disable.
When using FIFO, first you need to go into UART mode in a status of 0 [FIFO Disable]. By disabling FIFO in UART mode the FIFO sequencer is initialized.
SCCNT_L [d07] Data Length
Select data length as 8 bits or 7 bits.
SCCNT_L [d06] Error Flag
By referring to this error flag, the status of communication errors can be determined.
When it is 0, no errors have occurred. When it is set to 1, an error has occurred. By reading Register SCCNT_L, this error flag is reset.
Additionally, when there has been an error, the data from the Receive Shift Register is not written to the Receive Data Register. The conditions associated with each error are described below.
ERROR NAME | CONDITION |
Framing Error | The receive data stop bit is not 0 |
Parity Error | When parity is enabled, there is an error in the parity for the receive data |
Overrun Error | When FIFO is invalid, if the receive data is not empty (SCCNT_L[d05]=0 and next receive has ended (detect stop bit). Or when FIFO is valid, if receive FIFO is full and next communication has ended (detect stop bit). |
SCCNT_L [d05] Receive Data Flag
When set to 0, there is still data present.
When set to 1, it is empty.
SCCNT_L [d04] Send Data Flag
When set to 0, it is not full.
After one send operation ends this is reset.
When set to 1, it is full.
Set during a write of data to the lower 8 bits of the Send Data Register SCCNT_H.
SCCNT_L [d03] Parity Control
Switches between even parity and odd parity.
SCCNT_L [d02] CTS Flag
The SD terminal of the other machine (receive enable/disable) is input to the SC terminal.
When set to 0, a send is always possible independent of the SC Terminal.
When set to 1, a send is only possible when a LO is being input to the SC Terminal.
SCCNT_L [d01-d00] Baud Rate
Sets communication baud rate.
Setting |
Baud Rate |
00 |
9600 bps |
01 |
38400 bps |
10 |
57600 bps |
11 |
115200 bps |
Setting (d13, d12) = (1, 0) initiates the general purpose communication mode.
In this mode, all of the terminals SI, SO, SC, and SD become pull-up and operate as general purpose input/output terminals. Each of the communication terminals SI, SO, SC, and SD can be directly controlled.
R [d15-d14] Communication Function Set Flag
When set to 00 or 01, operates as a serial communication(8-bit/16-bit serial communication, multi-player communication, UART communication function) terminal.
When set to 10, can be used as a general purpose input/output terminal.
When set to 11, can be used as a JOY Bus communication terminal.
R [d08] Interrupt Request Enable Flag
When general purpose input/output is set(R[d15,d14]=[1,0]) with the communication function set flag, a 1 causes an interrupt request to be generated with the falling of the SI Terminal(edge detect).
When set to 0, no interrupt request is generated.
R [d07-d04] Input/Output Selection Flag
When general purpose input/output is set(R[d15,d14]=[1,0]) with the communication function set flag, a setting of 0 allows the corresponding terminal to be used as an input terminal. A setting of 1 allows the corresponding terminal to be used as an output terminal.
[Caution]
Always set the SI terminal to an input. If it is set to an output, a problem may occur with some connecting equipment.
R [d03-d00] Data Bit
When the corresponding terminal is set for input, the status(HI/LO) of the terminal can be confirmed. If the corresponding terminal is set for output, the status of the set bit is output.
By setting the communication function set flag to 11 for Register R, JOY Bus communication mode is selected. In JOY Bus communication mode, the SI Terminal is for input, and SO Terminal is for output. SD and SC Terminals go to LO output.
HS_CRTL [d05] Interrupt Request Enable Flag
When set to 0, an interrupt request is not generated.
When set to 1, an interrupt request is generated once a device reset command is received.
HS_CRTL [d02] Send Complete Flag
Set upon completion of send operation.
When this is set, if you write a 1, a reset can be done.
HS_CRTL [d01] Receive Complete Flag
Set upon completion of receive operation.
When this is set, if you write a 1, a reset can be done.
HS_CRTL [d00] Device Reset Signal Receive Flag
Set when a device reset command is received.
When this is set, if you write a 1, a reset can be done.
The lower 8-bits of the receive status register JSTAT is returned as the communication status.
JSTAT [d05,d04] General Purpose Flag
This flag is not assigned.
The user can set the use of this flag arbitrarily.
JSTAT [d03] Send Status Flag
When an AGB write data signal is received, this is set. If a word read is done with the JOYRE Register it is reset.
JSTAT [d01] Receive Status Flag
When a word write is done with the JOYTR Register, this is set. If an AGB read data signal is received it is reset.
AGB JOY Bus communication recognizes four commands sent from the host (N64, etc.): [Device Reset], [Type/Status Data Request], [AGB Data Write], and [AGB Data Read]. AGB operates based on the particular signal received.
The transfer of the bit data for JOY Bus communication is done in units of bytes and in the order of MSB first.
The device reset signal receive flag for Register HS_CTRL is set.
If the interrupt request enable flag for the same register is also set, a JOY Bus interrupt request is generated.
Direction |
Order |
d7 |
d6 |
d5 |
d4 |
d3 |
d2 |
d1 |
d0 |
Remarks |
Receive |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
Command 255(FFh) |
Send |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Type Number 0400h |
2 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
||
3 |
Lower 8 bits of Register JSTAT |
Communication Status |
Returns 2 byte type number(0004h) and 1 byte communication status.
Direction |
Order |
d7 |
d6 |
d5 |
d4 |
d3 |
d2 |
d1 |
d0 |
Remarks |
Receive |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Command 0(00h) |
Send |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Type Number 0400h |
2 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
||
3 |
Lower 8 bits of Register JSTAT |
Communication Status |
Receives the 4 bytes of data sent following this command, and stores them in Register JOYRE. Once the receive is completed a 1 byte communication status is returned, and the receive complete flag for Register HS_CTRL is set. Also, if the interrupt request enable flag for the same register is set, a JOY Bus interrupt request is generated.
Direction |
Order |
d7 |
d6 |
d5 |
d4 |
d3 |
d2 |
d1 |
d0 |
Remarks |
Receive |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
0 |
1 |
Command 21(15h) |
Receive |
2 |
Lower 8 bits of receive data Register JOYRE_L |
Receive Data |
|||||||
3 |
Upper 8 bits of receive data Register JOYRE_L |
|||||||||
4 |
Lower 8 bits of receive data Register JOYRE_H |
|||||||||
5 |
Upper 8 bits of receive data Register JOYRE_H |
|||||||||
Send |
6 |
Lower 8 bits of Register JSTAT |
Communication Status |
4 bytes of data stored in Register JOYTR and the 1 byte communication status are sent, and the send complete flag for Register HS_CTRL is set.
Also, if the interrupt request enable flag for the same register is set, a JOY Bus interrupt request is generated.
Direction |
Order |
d7 |
d6 |
d5 |
d4 |
d3 |
d2 |
d1 |
d0 |
Remarks |
Receive |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
Command 20(14h) |
Send |
2 |
Lower 8 bits of send data Register JOYTR_L |
Send Data |
|||||||
3 |
Upper 8 bits of send data Register JOYTR_L |
|||||||||
4 |
Lower 8 bits of send data Register JOYTR_H |
|||||||||
5 |
Upper 8 bits of send data Register JOYTR_H |
|||||||||
6 |
Lower 8 bits of Register JSTAT |
Communication Status |
When communicating between AGB units, the communication cable to be used will vary depending upon the type of Game Pak used.